#include "network.h"
#define ERROR                       -1
#define AUTO                        0
#define MAX_LISTEN_QUEUE_NUMBER     10


network::network()
{

}

void *network::AcceptTCPConnect(void *arg)
{
    log = MyLog::getInstance();
    int ret = -1;
    serverLen = sizeof(sockaddr_in);
    try {
        serverFd = socket(AF_INET, SOCK_STREAM, AUTO);
        if (serverFd == ERROR){
            log->writeErrorLog("Server creat sockert Error");
        }

        ret = bind(serverFd, (sockaddr *)&server, serverLen);
        if (ret == ERROR){
            log->writeErrorLog("Server bind Error");
        }
        
        ret = listen(serverFd, MAX_LISTEN_QUEUE_NUMBER);
        if (ret == ERROR){
            log->writeErrorLog("Server set listen Error");
        }
    }catch(...){

    }
}


bool network::CreateServer(in_port_t server_port,in_addr_t ipv4_addr = INADDR_ANY)
{
    pthread_t t_id;
    



}

